package com.newworld.basketballfire.main.utils;

import com.newworld.basketballfire.main.api.DuesType;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.UUID;

/**
 * Created by George on 2019/3/3.
 * CommonUtils
 */
public class CommonUtils {

    public static String getUUID() {
        return UUID.randomUUID().toString().replace("-", "");
    }

    public static long getCurrentTime() {
        return System.currentTimeMillis();
    }

    public static BigDecimal adjustDuesValue(int type, BigDecimal dues) {
        if (type == DuesType.CONSUME.getValue() && dues.compareTo(BigDecimal.ZERO) > 0
                || type == DuesType.RECHARGE.getValue() && dues.compareTo(BigDecimal.ZERO) < 0) {
            return dues.negate();
        }
        return dues;
    }

    public static int getCurIndex(int pageNo, int pageSize) {
        return Math.max((pageNo - 1) * pageSize, 0);
    }

}
